import java.io.PrintStream;
import java.util.Scanner;

public class task03
{

    public task03()
    {
    }

    public static void main(String args[])
    {
        Scanner input = new Scanner(System.in);
        String str = input.next();
        String name[] = null;
        String kinds[] = null;
        String math[] = null;
        String bl[] = null;
        name = pack(str);
        name = exchang(name);
        kinds = kinds(name);
        math = kinds1(kinds);
        bl = del(kinds, math);
        print(name);
        System.out.println();
        System.out.println("\u79CD\u7C7B\u6709");
        print(bl);
    }

    public static String[] del(String kinds[], String math[])
    {
        int al[] = new int[kinds.length];
        String bl[] = new String[kinds.length];
        for(int i = 0; i < kinds.length; i++)
        {
            int a = 0;
            for(int j = i; j < kinds.length; j++)
                if(kinds[i].equals(kinds[j]) && ++a != 1)
                    al[j] = 1;

        }

        int j = 0;
        for(int i = 0; i < kinds.length; i++)
            if(al[i] != 1)
            {
                bl[j] = kinds[i] + "\t" + math[i];
                j++;
            }

        return bl;
    }

    public static String[] exchang(String name[])
    {
        for(int i = 0; i < name.length; i++)
        {
            String first = name[i].substring(0, 1).toUpperCase();
            String rest = name[i].substring(1, name[i].length());
            name[i] = first + rest;
        }

        return name;
    }

    public static String[] pack(String str)
    {
        int i = 0;
        int j = 0;
        int place[] = new int[1024];
        while((i = str.indexOf(",", i + 1)) != -1) 
        {
            place[j] = i;
            j++;
        }
        String name[] = new String[++j];
        name = pack1(str, place, j);
        return name;
    }

    public static String[] pack1(String str, int place[], int j)
    {
        String name[] = new String[j];
        int i;
        for(i = 0; place != null && place[i] != 0; i++)
            if(i == 0)
                name[i] = str.substring(0, place[i]);
            else
                name[i] = str.substring(place[i - 1] + 1, place[i]);

        name[i] = str.substring(place[i - 1] + 1);
        return name;
    }

    public static void print(String name[])
    {
        for(int i = 0; i < name.length; i++)
            if(name[i] != null)
                System.out.println(name[i] + "\t");

    }

    public static String[] kinds(String name[])
    {
        int kinds[] = null;
        String houzhui[] = null;
        kinds = kind(name);
        houzhui = kind(name, kinds);
        return houzhui;
    }

    public static String[] kinds1(String houzhui[])
    {
        String math[] = new String[houzhui.length];
        for(int j = 0; j < houzhui.length; j++)
        {
            int a = 0;
            for(int k = j; k < houzhui.length; k++)
                if(houzhui[j].equals(houzhui[k]))
                    a++;

            if(a != 0)
                math[j] = String.valueOf(a);
        }

        return math;
    }

    public static int[] kind(String name[])
    {
        int place[] = new int[name.length];
        for(int i = 0; i < name.length; i++)
            place[i] = name[i].indexOf(".");

        return place;
    }

    public static String[] kind(String name[], int place[])
    {
        String houzhui[] = new String[name.length];
        for(int i = 0; i < name.length; i++)
            houzhui[i] = name[i].substring(place[i] + 1);

        return houzhui;
    }
}
